<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>

<body>
    <div id="app">
        <!-- 计算属性 -->
        简单方式输出：{{computedName}} 完整写法输出：{{compName}}
    </div>

</body>
<script>
    var vm = new Vue({
        el: "#app",
        data: {
            Name: "ttome"

        },
        // 定义属性
        computed: {
            computedName() {
                // 首字母大写
                return this.Name.substr(0, 1).toUpperCase() + this.Name.substr(1)
            },
            compName: {
                get() {
                    return this.Name.substr(0, 1).toUpperCase() + this.Name.substr(1)
                },
                set(data) {
                    this.Name = data;
                }
            }
        }
    })
</script>

</html>